home *** CD-ROM | disk | FTP | other *** search
/ Your Choice 1 / your choice.zip / your choice / PRGMMING / CX201 / VBCXF.FRM < prev    next >
Text File  |  1994-03-01  |  8KB  |  274 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "CXF"
  4.    Height          =   5445
  5.    Left            =   1065
  6.    LinkTopic       =   "Form1"
  7.    MaxButton       =   0   'False
  8.    MinButton       =   0   'False
  9.    ScaleHeight     =   5040
  10.    ScaleWidth      =   5055
  11.    Top             =   1140
  12.    Width           =   5175
  13.    Begin TextBox dtext 
  14.       Height          =   285
  15.       Left            =   2160
  16.       TabIndex        =   2
  17.       Text            =   "c:\test2.cxf"
  18.       Top             =   960
  19.       Width           =   2535
  20.    End
  21.    Begin TextBox ctext 
  22.       Height          =   285
  23.       Left            =   2160
  24.       TabIndex        =   1
  25.       Text            =   "c:\test1.cxf"
  26.       Top             =   600
  27.       Width           =   2535
  28.    End
  29.    Begin TextBox itext 
  30.       Height          =   285
  31.       Left            =   2160
  32.       TabIndex        =   0
  33.       Top             =   240
  34.       Width           =   2535
  35.    End
  36.    Begin CommandButton decompress 
  37.       Caption         =   "decompress"
  38.       Height          =   495
  39.       Left            =   240
  40.       TabIndex        =   4
  41.       Top             =   2160
  42.       Width           =   1935
  43.    End
  44.    Begin Frame method 
  45.       Caption         =   "Compression"
  46.       Height          =   2175
  47.       Left            =   2760
  48.       TabIndex        =   6
  49.       Top             =   1440
  50.       Width           =   1935
  51.       Begin OptionButton methodd 
  52.          Caption         =   "CX_METHODD"
  53.          Height          =   255
  54.          Left            =   120
  55.          TabIndex        =   12
  56.          Top             =   1800
  57.          Width           =   1695
  58.       End
  59.       Begin OptionButton methodc 
  60.          Caption         =   "CX_METHODC"
  61.          Height          =   255
  62.          Left            =   120
  63.          TabIndex        =   11
  64.          Top             =   1440
  65.          Width           =   1695
  66.       End
  67.       Begin OptionButton method3 
  68.          Caption         =   "CX_METHOD3"
  69.          Height          =   255
  70.          Left            =   120
  71.          TabIndex        =   10
  72.          Top             =   1080
  73.          Width           =   1695
  74.       End
  75.       Begin OptionButton method2 
  76.          Caption         =   "CX_METHOD2"
  77.          Height          =   255
  78.          Left            =   120
  79.          TabIndex        =   9
  80.          Top             =   720
  81.          Width           =   1695
  82.       End
  83.       Begin OptionButton method1 
  84.          Caption         =   "CX_METHOD1"
  85.          Height          =   255
  86.          Left            =   120
  87.          TabIndex        =   8
  88.          Top             =   360
  89.          Value           =   -1  'True
  90.          Width           =   1695
  91.       End
  92.    End
  93.    Begin Timer ptimer 
  94.       Enabled         =   0   'False
  95.       Interval        =   1000
  96.       Left            =   2280
  97.       Top             =   2760
  98.    End
  99.    Begin CommandButton Cancel 
  100.       Caption         =   "Cancel"
  101.       Enabled         =   0   'False
  102.       Height          =   495
  103.       Left            =   240
  104.       TabIndex        =   5
  105.       Top             =   2880
  106.       Width           =   1935
  107.    End
  108.    Begin CommandButton Compress 
  109.       Caption         =   "Compress"
  110.       Height          =   495
  111.       Left            =   240
  112.       TabIndex        =   3
  113.       Top             =   1440
  114.       Width           =   1935
  115.    End
  116.    Begin Label notice 
  117.       Caption         =   "The evaluation object code runs MUCH slower than the object code that may be purchased.  Use TEST.EXE for EXACT size and speed measurements."
  118.       Height          =   615
  119.       Left            =   240
  120.       TabIndex        =   17
  121.       Top             =   4320
  122.       Width           =   4575
  123.    End
  124.    Begin Label dlabel 
  125.       Caption         =   "Decompressed File:"
  126.       Height          =   255
  127.       Left            =   360
  128.       TabIndex        =   16
  129.       Top             =   960
  130.       Width           =   1815
  131.    End
  132.    Begin Label olabel 
  133.       Caption         =   "Compressed File:"
  134.       Height          =   255
  135.       Left            =   360
  136.       TabIndex        =   15
  137.       Top             =   600
  138.       Width           =   1575
  139.    End
  140.    Begin Label ilabel 
  141.       Caption         =   "Input File:"
  142.       Height          =   255
  143.       Left            =   360
  144.       TabIndex        =   14
  145.       Top             =   240
  146.       Width           =   975
  147.    End
  148.    Begin Label size 
  149.       Height          =   255
  150.       Left            =   360
  151.       TabIndex        =   13
  152.       Top             =   3840
  153.       Width           =   2055
  154.    End
  155.    Begin Label progress 
  156.       Height          =   255
  157.       Left            =   2760
  158.       TabIndex        =   7
  159.       Top             =   3840
  160.       Width           =   2055
  161.    End
  162. End
  163. Dim continue As Integer
  164. Dim bytes As Long
  165. Dim start As Single
  166.  
  167. Sub Cancel_Click ()
  168.     continue = False
  169. End Sub
  170.  
  171. Sub Compress_Click ()
  172.     Dim method As Integer
  173.     Dim i As Integer
  174.  
  175.     If method1.Value Then method = CX_METHOD1
  176.     If method2.Value Then method = CX_METHOD2
  177.     If method3.Value Then method = CX_METHOD3
  178.     If methodc.Value Then method = CX_METHODC
  179.     If methodd.Value Then method = CX_METHODD
  180.  
  181.     src$ = itext.Text
  182.     dst$ = ctext.Text
  183.     
  184.     start_progress
  185.     i = cx_compress_file(dst$, src$, method, CX_MAX_BUFFER, CX_C_MAXTEMP, continue, bytes)
  186.     stop_progress
  187.  
  188.     If Not continue Then
  189.         MsgBox "Canceled by operator", MB_ICONOK, "CXF"
  190.     Else
  191.         If i = 0 Then
  192.             size.Caption = diffstr(filelength(dst$), filelength(src$))
  193.             MsgBox "File Compressed", MB_ICONOK, "CXF"
  194.         Else
  195.             s$ = cx_error_message(itol(i))
  196.             MsgBox s$, MB_ICONOK, "CXF ERROR"
  197.         End If
  198.     End If
  199. End Sub
  200.  
  201. Sub decompress_Click ()
  202.     Dim i As Integer
  203.  
  204.     src$ = ctext.Text
  205.     dst$ = dtext.Text
  206.  
  207.     start_progress
  208.     i = cx_decompress_file(dst$, src$, continue, bytes)
  209.     stop_progress
  210.  
  211.     If Not continue Then
  212.         MsgBox "Canceled by operator", MB_ICONOK, "CXF"
  213.     Else
  214.         If i = 0 Then
  215.             size.Caption = diffstr(filelength(dst$), filelength(src$))
  216.             MsgBox "File Decompressed", MB_ICONOK, "CXF"
  217.         Else
  218.             s$ = cx_error_message(itol(i))
  219.             MsgBox s$, MB_ICONOK, "CXF ERROR"
  220.         End If
  221.     End If
  222.  
  223. End Sub
  224.  
  225. Function diffstr (a As Long, b As Long) As String
  226.     diffstr = Format(a / b, "###0.00") + " of input"
  227. End Function
  228.  
  229. Function filelength (s As String) As Long
  230.     Dim h As Integer
  231.     Dim l As Long
  232.  
  233.     h = binio_open(s, BINIO_OPEN_READ)
  234.     If h = -1 Then
  235.         filelength = -1
  236.     Else
  237.         l = binio_length(h)
  238.         If l = -1 Then filelength = -1 Else filelength = l
  239.         k% = binio_close(h)
  240.     End If
  241. End Function
  242.  
  243. Sub ptimer_Timer ()
  244.     Dim t As Single
  245.  
  246.     t = Timer - start
  247.     If t = 0# Then
  248.         progress.Caption = "0 K/sec"
  249.     Else
  250.         progress.Caption = Format$(bytes / (t * 1024), "###0.00") + " K/sec"
  251.     End If
  252. End Sub
  253.  
  254. Sub start_progress ()
  255.     compress.Enabled = False
  256.     decompress.Enabled = False
  257.     cancel.Enabled = True
  258.     size.Caption = ""
  259.     progress.Caption = ""
  260.     continue = True
  261.     bytes = 0
  262.     start = Timer
  263.     ptimer.Enabled = True
  264. End Sub
  265.  
  266. Sub stop_progress ()
  267.     compress.Enabled = True
  268.     decompress.Enabled = True
  269.     cancel.Enabled = False
  270.     ptimer.Enabled = False
  271.     ptimer_Timer
  272. End Sub
  273.  
  274.